<template>
<div class="select">
    <b style="margin-right:15px;margin-left:29px">
        学科
    </b>
    <el-select v-model="value" placeholder="请选择" style="width:300px" @change="sendSubId">
        <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.subjectName"
        :value="item.id">
        </el-option>
    </el-select>
</div>
</template>

<script>
import { list } from '@/api/hmmm/subjects'
export default {
  name: 'selected-sub',
  data () {
    return {
      options: [],
      value: null // 学科的id
    }
  },
  created () {
    this.loading()
  },
  methods: {
    // 获取学科数据
    async loading () {
      const res = await list()
      this.options = res.data.items
    },
    // 将学科id传给父组件
    sendSubId () {
      this.$emit('getSubId', this.value)
      this.$emit('delCatalogID')
    }
  }
}
</script>

<style>

</style>
